import org.mockito.Mockito;
import org.testng.Assert;
import org.testng.annotations.Test;
public class UserServiceMockIntegrationTest {
    @Test
    public void testLoginWithMock() {
        UserDao mockDao = Mockito.mock(UserDao.class);
        Mockito.when(mockDao.findUser("admin"))
                .thenReturn(new User("admin", "123456"));
        UserService userService = new UserService(mockDao);
        boolean loginSuccess = userService.login("admin", "123456");
        Assert.assertTrue(loginSuccess, "使⽤Mock对象，⽤户应登录成功");
    }
}